<!DOCTYPE HTML>
<html>
	<head>
		<script type="text/javascript" src="../Oak3D_v_0_5_9.js"></script>
		<script type="text/javascript">
			function load(){
				var ifWebglSupport = okIsSupportWebGL();
				if (!ifWebglSupport){
					alert("Sorry, your browser doesn't support WebGL!");
					return ;
				}
				var myCanvas = okGenCanvas(800, 600, document.getElementById("RenderArea"));
				var myEngineSetting = new okEngineSetting();
				myEngineSetting.canvas = myCanvas;
				myEngine = new okEngine();
				var ifEngineInitialize = myEngine.init(myEngineSetting);
				if (!ifEngineInitialize){
					alert("Sorry, failed to initialize Oak3D engine!");
					return ;
				}
				var mySceneManager = myEngine.getSceneManager();
				var myScene = mySceneManager.createScene("myScene");
				var myCamera = myScene.createCamera();
				myCamera.setViewport(0, 0, 800, 600); //set the viewport of the camera
				myCamera.setBackColor(0.0, 0.0, 0.0, 1.0); //set the back ground color of the camera viewport
				myCamera.setProjMode(OAK.PROJMODE_PERSPECTIVE); //set the projection mode
				myCamera.setFov(45) //set field of view
				myCamera.setVisibleRange(1.0, 10000.0); //set visible distance
				myCamera.setPos(0.0, 0.0, 20);   //set the camera position
					
				var mySphere = myScene.createEntity(OAK.ETYPE_CUSTOM_MESH, "MySphere");
				var mySphereMesh = mySphere.getMesh();
				okGenSphereMesh(mySphereMesh, 5, 30, 30, true);
				mySphere.computeBoundingBox();
				mySphere.setPos(0, 0, 0);
				mySphere.getMaterial().enableWireframe(true);
				mySphere.getMaterial().setEmissive(1, 1, 1);

				var myRenderer = myEngine.getRenderer();
				myRenderer.beginView(myCamera);
				myRenderer.renderScene(myScene);
				myRenderer.endView();

				//present the image to the canvas
				myRenderer.present();
	
			}
		</script>
	</head>
	<body onload="load()">
	<div id="RenderArea"></div>
	</body>
</html>